package com.suzhouhe.util.config.date;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.suzhouhe.util.utils.DateUtil;

import java.io.IOException;
import java.time.LocalDateTime;

/**
 * 时间序列化处理 将long类型的时间戳转换为LocalDateTime
 *
 * @author suzhouhe
 * @date 2020-08-18 11:58
 **/
public class RequestLongToLocalDateTimeDeserializer extends JsonDeserializer<LocalDateTime> {

    @Override
    public LocalDateTime deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
        String value = jsonParser.getValueAsString();
        return DateUtil.longToLocalDateTime(Long.valueOf(value));
    }
}
